﻿<h1>Editable GridView Control Example</h1>
This example explains how to create a window with an editable GridView control, bind to the data and show on the screen. <br>GridView is editable because we use <i>gridviewtextboxcolumn</i> column types.<br>
<button id="EditableGridViewExample" class="try-example-button">Try Example</button>
<h2>UI Model</h2>
<div style="color:Black;background-color:White;"><pre>{
    <span style="color:#A31515;">"windows"</span>: [
        {
            <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"EditableGridViewExample"</span>,
            <span style="color:#A31515;">"title"</span>: <span style="color:#A31515;">"Editable GridView Example"</span>,
            <span style="color:#A31515;">"width"</span>: 500,
            <span style="color:#A31515;">"height"</span>: 300,
            <span style="color:#A31515;">"controls"</span>: [
                <b>{
                    <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"managersGrid"</span>,
                    <span style="color:#A31515;">"type"</span>: <span style="color:#A31515;">"gridview"</span>,
                    <span style="color:#A31515;">"bindsTo"</span>: <span style="color:#A31515;">"list"</span>,
                    <span style="color:#A31515;">"canUserAddRows"</span>: <span style="color:Blue;">false</span>,
                    <span style="color:#A31515;">"columns"</span>: [
                        {
                            <span style="color:#A31515;">"type"</span>: <span style="color:#A31515;">"gridviewtextboxcolumn"</span>,
                            <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"title"</span>,
                            <span style="color:#A31515;">"label"</span>: <span style="color:#A31515;">"Title"</span>,
                            <span style="color:#A31515;">"width"</span>: 170,
                            <span style="color:#A31515;">"bindsTo"</span>: <span style="color:#A31515;">"title"</span>
                        },
                        {
                            <span style="color:#A31515;">"type"</span>: <span style="color:#A31515;">"gridviewtextboxcolumn"</span>,
                            <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"name"</span>,
                            <span style="color:#A31515;">"label"</span>: <span style="color:#A31515;">"Name"</span>,
                            <span style="color:#A31515;">"width"</span>: 280,
                            <span style="color:#A31515;">"bindsTo"</span>: <span style="color:#A31515;">"name"</span>
                        }
                    ]
                }</b>,
                {
                    <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"OKButton"</span>,
                    <span style="color:#A31515;">"type"</span>: <span style="color:#A31515;">"button"</span>,
                    <span style="color:#A31515;">"text"</span>: <span style="color:#A31515;">"OK"</span>,
                    <span style="color:#A31515;">"isDialogButton"</span>: <span style="color:Blue;">true</span>,
                    <span style="color:#A31515;">"dialogResult"</span>: <span style="color:#A31515;">"OK"</span>
                },
                {
                    <span style="color:#A31515;">"name"</span>: <span style="color:#A31515;">"CancelButton"</span>,
                    <span style="color:#A31515;">"type"</span>: <span style="color:#A31515;">"button"</span>,
                    <span style="color:#A31515;">"text"</span>: <span style="color:#A31515;">"Cancel"</span>,
                    <span style="color:#A31515;">"isDialogButton"</span>: <span style="color:Blue;">true</span>,
                    <span style="color:#A31515;">"dialogResult"</span>: <span style="color:#A31515;">"Cancel"</span>
                }
            ]
        }
    ]
}
</pre></div>
<h2>Data Model</h2>
<div style="color:Black;background-color:White;"><pre><span style="color:Blue;">var</span> teamManagement = {
	list: [
		{
			id: 7,
			title: <span style="color:#A31515;">"Manager"</span>,
			name: <span style="color:#A31515;">"Fiorello Lombardi"</span>,
		},
		{
			id: 8,
			title: <span style="color:#A31515;">"Goalkeeping Coach"</span>,
			name: <span style="color:#A31515;">"Armando Arcuri"</span>,
		},
		{
			id: 9,
			title: <span style="color:#A31515;">"Assistant Manager"</span>,
			name: <span style="color:#A31515;">"Alessio Ferri"</span>,
		},
		{
			id: 10,
			title: <span style="color:#A31515;">"First-team Coach"</span>,
			name: <span style="color:#A31515;">"Giuseppe Milani"</span>,
		}
	]
};
<pre><span style="color:Blue;">var</span> exampleWindow = redui.createNewWindow(<span style="color:#A31515;">"EditableGridViewExample"</span>);
exampleWindow.bind(teamManagement);
exampleWindow.show();

exampleWindow.closed(<span style="color:Blue;">function</span> (target, dialogResult) {
	alert(<span style="color:#A31515;">"GridView data: "</span> + JSON.stringify(exampleWindow.managersGrid.bindingContext));
});
</pre>